﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class admin_qljoblang : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {

    }
    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        e.Cancel = true;
        Label id = (Label)this.GridView1.Rows[e.NewEditIndex].Cells[0].FindControl("id");
        Label lang = (Label)this.GridView1.Rows[e.NewEditIndex].Cells[1].FindControl("lang");
        Response.Redirect("Default.aspx?page=edjoblang&id=" + id.Text + "&lang=" + lang.Text);
    }
    protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
    {

    }
    protected void addbt_Click(object sender, EventArgs e)
    {
        hdfContent.Value = fckContent.Value;
        try
        {
            SqlDataSource2.Insert();
            SqlDataSource2.DataBind();
            Response.Write("<script>alert('Insert Thành Công')</script>");
            this.fckContent.Value = "";
            this.txtTitle.Text = "";
            this.menu.Text = "";
            this.hdfContent.Value = "";
            this.ddlID.SelectedIndex = 0;
            this.ddlLang.SelectedIndex = 0;
            reset();
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('Thất bại. Vui lòng kiểm tra lai dữ liệu')</script>");
        }
        
    }
    protected void ddlLang_SelectedIndexChanged(object sender, EventArgs e)
    {
        reset();
    }

    private void reset()
    {
        SqlDataSource3.DataBind();
        ddlID.DataBind();
    }
    protected void ddlLang_DataBound(object sender, EventArgs e)
    {
        reset();
    }
    protected void GridView1_RowDeleted(object sender, GridViewDeletedEventArgs e)
    {
        
        Response.Redirect(Request.Url.ToString());
    }
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        e.Cancel = true;
        Response.Write(Common.confirmDelete(null));
    }
}